package com.kaba.xtzhgl.controller;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.kaba.bean.ResponseResult;
import com.kaba.bean.ResultCode;
import com.kaba.bean.SysMenu;
import com.kaba.xtzhgl.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author lvmengjie
 * @Date 2021/3/16
 * @Description TODO
 */
@RestController
@RequestMapping("/sysmenu")
@CrossOrigin
public class SysMenuContorller {

    @Autowired
    private SysMenuService sysMenuService;
    /**
     * 列表显示所有
     * */

    @GetMapping("/queryMenu")
    public ResponseResult queryMenu(){
        List<SysMenu> lsitmenu=sysMenuService.queryMenu();
        return ResponseResult.success(ResultCode.SUCCESS,lsitmenu);
    }
    /**
     *综合查询
     *
     */
    @GetMapping("/zhcx")
    public ResponseResult zhcx(SysMenu sysMenu){
        List<SysMenu> zhcxlist=sysMenuService.zhcx(sysMenu);
        return ResponseResult.success(ResultCode.SUCCESS,zhcxlist);
    }
    /**
     *删除
     *
     */
    @DeleteMapping("/deleteMenu/{menuId}")
    public ResponseResult deleteMenu(@PathVariable Integer menuId){
        UpdateWrapper wrapper=new UpdateWrapper();
        wrapper.eq("menu_id",menuId);
        wrapper.set("visible","1");
        sysMenuService.update(wrapper);
        return  ResponseResult.error(ResultCode.SUCCESS);
    }

    @GetMapping("/getmenulist")
    public ResponseResult getmenulist(){

        List<SysMenu> list=sysMenuService.list();
        return ResponseResult.success(ResultCode.SUCCESS,list);

    }



}
